/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.model.core;

/**
 * <p>Represents global property. Global property is a pair <em>name, value</em>:
 * that's <em>value</em>, corresponding to global property named <em>name</em>.
 * </p>
 * <p>
 * Global properties are used to specify some parameters that are common for
 * whole application. They can be static and dynamic. Static properties are
 * those that were defined in configuration files, they can't be changed at
 * runtime. Dynamic properties are those that can be edited through
 * web-interface -- they influence application behaviour at runtime.
 * </p>
 * <p><a href="GlobalProperty.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author Sergey Zubtsovskiy <a href="mailto:sergey.zubtsovskiy@blandware.com">&lt;sergey.zubtsovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.12 $ $Date: 2006/08/03 10:07:34 $
 * @hibernate.class table="`al_core_global_property`" lazy="false"
 */
public class GlobalProperty extends BaseObject {

	//~ Instance variables

    /**
     * Name of global property
     */
	protected String name;
    /**
     * Value of global property
     */
	protected String value;
    /**
     * Version of this global property (used in optimistic locking)
     */
	protected Long version;

	//~ Constructors

	/**
	 * Creates new instance of GlobalProperty
	 */
	public GlobalProperty() {
	}

	/**
	 * Creates new instance of GlobalProperty with the specified name
	 *
	 * @param name Name of property
	 */
	public GlobalProperty(String name) {
		this.name = name;
	}

	/**
	 * Creates new instance of GlobalProperty with the specified name and value
	 *
	 * @param name  Name of property
	 * @param value Value of property
	 */
	public GlobalProperty(String name, String value) {
		this.name = name;
		this.value = value;
	}

	//~ Methods

	/**
     * Gets global property name
     *
     * @return name
	 * @hibernate.id column="`property_name`" generator-class="assigned"
	 * unsaved-value="null" length="252"
	 */
	public String getName() {
		return name;
	}

    /**
     * Sets global property name
     *
     * @param name name to set
     */
	public void setName(String name) {
		this.name = name;
	}

	/**
     * Gets global property value
     *
	 * @return value
	 * @hibernate.property column="`property_value`" not-null="false" unique="false" length="252"
	 */
	public String getValue() {
		return value;
	}

    /**
     * Sets global property value
     *
     * @param value value to set
     */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * Returns version of this global property
	 *
	 * @return version
	 * @hibernate.version column="`version`" type="long" unsaved-value="null"
	 */
	public Long getVersion() {
		return version;
	}

    /**
     * Sets version of this global property
     *
     * @param version version to set
     */
	public void setVersion(Long version) {
		this.version = version;
	}

	public boolean equals(Object o) {
		if ( this == o ) {
			return true;
		}
		if ( !(o instanceof GlobalProperty) ) {
			return false;
		}

		final GlobalProperty globalProperty = (GlobalProperty) o;

		if ( name != null ? !name.equals(globalProperty.name) : globalProperty.name != null ) {
			return false;
		}

		return true;
	}

	public int hashCode() {
		return (name != null ? name.hashCode() : 0);
	}

}

